package org.btik.lightweb.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.util.HashSet;

/**
 * 开发环境的拦截器，放行OPTIONS.
 *
 * @author lustre
 * @since 2023/6/18 0:52
 */
public class DevPermissionInterceptor extends PermissionInterceptor {

    public DevPermissionInterceptor(HashSet<String> adminPermission) {
        super(adminPermission);
    }

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if (request.getMethod().equals("OPTIONS")) {
            return true;
        }
        return super.preHandle(request, response, handler);
    }
}
